package jdbclianxi20250325;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo6 {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection();) {
            Statement statement = connection.createStatement();
            String sql = "select t.name,t.salary,c.name,c.floor " +
                    "from class c , teacher t " +
                    "where c.teacher_id=t.id " +
                    "and t.name = '王克晶'";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()){
                String tName = resultSet.getString("t.name");
                int tSalary = resultSet.getInt("t.salary");
                String cName = resultSet.getString("c.name");
                int cFloor = resultSet.getInt("c.floor");
                System.out.println(tName+","+tSalary+","+cName+","+cFloor);
                String line = String.join("$",tName,""+tSalary,cName,""+cFloor);
                System.out.println(line);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
